//
//  ZPBTwoCollectionViewCell.m
//  WZLProduct
//
//  Created by boys on 16/3/21.
//  Copyright © 2016年 HaiTeng. All rights reserved.
//

#import "ZPBTwoCollectionViewCell.h"

@implementation ZPBTwoCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.bgImage = [[UIImageView alloc] init];
        [self.contentView addSubview:_bgImage];
        
        self.titleLabel =[[UILabel alloc] init];
        [self.contentView addSubview:_titleLabel];
        
        self.likeLabel = [[UILabel alloc] init];
        [_bgImage addSubview:_likeLabel];
        
        self.aliLabel = [[UILabel alloc] init];
        [_bgImage addSubview:_aliLabel];
        
        self.sImage = [[UIImageView alloc] init];
        [_bgImage addSubview:_sImage];
    }
    return self;
}

-(void)layoutSubviews {
    [super layoutSubviews];
    [_bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.offset(0);
        make.width.height.offset((kScreenWidth - 40)/ 3);
    }];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.right.offset(0);
        make.width.equalTo(_bgImage);
        make.height.offset(40);
    }];
    [_likeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(3);
        make.right.offset(-5);
        make.width.offset(40);
        make.height.offset(15);
    }];
    [_sImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_likeLabel);
        make.right.equalTo(self.likeLabel.mas_left).with.offset(-5);
        make.width.offset(15);
        make.height.equalTo(_likeLabel);
    }];
    [_aliLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(5);
        make.bottom.offset(-3);
        make.width.offset(50);
        make.height.offset(20);
    }];
}

-(void)setModel:(ZPBSecondGetModel *)model {
    if (model) {
        [self.bgImage sd_setImageWithURL:[NSURL URLWithString:model.picUrl] placeholderImage:nil];
        self.titleLabel.text = model.name;
        _titleLabel.font = FONT16;
        _titleLabel.numberOfLines = 2;
        self.aliLabel.text = model.desc;
        
        _aliLabel.font = FONT10;
        _aliLabel.textColor = [UIColor whiteColor];
        self.sImage.image = [UIImage imageNamed:@"iconfont-erji.png"];
        _likeLabel.text = [NSString stringWithFormat:@"%@",model.listenCount];
        _likeLabel.font = FONT10;
        _likeLabel.textColor= [UIColor whiteColor];
    }
}


@end
